﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace MyMainSite
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("{resource}.ashx/{*pathInfo}");

            routes.MapRoute(
                "dateRoute",
                "blog/date/{year}/{month}",
                new { controller = "Blog", action = "Date", year = UrlParameter.Optional, month = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "searchRoute",
                "Search/index/{term}",
                new { controller = "Search", action = "index", term = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "projectsRoute",
                "Projects/index/{name}",
                new { controller = "Projects", action = "index", name = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "imagesRoute",
                "Projects/images/{projectId}",
                new { controller = "Projects", action = "images", projectId = UrlParameter.Optional } // Parameter defaults
			);

			routes.MapRoute(
				"adminRoute",
				"Admin/{action}/{projectId}",
				new { controller = "Admin", action = "index", projectId = UrlParameter.Optional } // Parameter defaults
			);

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{blogFriendlyUrl}/{title}", // URL with parameters
                new { controller = "Blog", action = "Index", blogFriendlyUrl = UrlParameter.Optional, title = UrlParameter.Optional } // Parameter defaults
            );
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }
}